library(tidyverse)         # for graphing and data cleaning
library(tidymodels)        # for modeling
library(naniar)            # for analyzing missing values
library(vip)               # for variable importance plots
theme_set(theme_minimal()) # Lisa's favorite theme
hotels <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-02-11/hotels.csv')

When you finish the assignment, remove the # from the options chunk at the top, so that messages and warnings aren’t printed. If you are getting errors in your code, add error = TRUE so that the file knits. I would recommend not removing the # until you are completely finished.

Put it on GitHub!

From now on, GitHub should be part of your routine when doing assignments. I recommend making it part of your process anytime you are working in R, but I’ll make you show it’s part of your process for assignments.

Task: When you are finished with the assignment, post a link below to the GitHub repo for the assignment.

https://github.com/bennywags15/Assignment_02

Machine Learning review and intro to tidymodels

Read through and follow along with the Machine Learning review with an intro to the tidymodels package posted on the Course Materials page.

Tasks:

  1. Read about the hotel booking data, hotels, on the Tidy Tuesday page it came from. There is also a link to an article from the original authors. The outcome we will be predicting is called is_canceled.
  • Without doing any analysis, what are some variables you think might be predictive and why?

The first two variables that stand out are the babies and children variables. Having kids can be a big task that gets in the way of traveling, thus they might play a role in whether the booking is canceled. Also, previous_cancellations will play a role. Someone who canceled in the past may be more prone to canceling again maybe because of their schedule.

_ What are some problems that might exist with the data? You might think about how it was collected and who did the collecting.

The data was collected by people in the hotel industry, with the intent to maximize their hotel’s profits. Thus, they have a bias as to what variables to collect and what information to extract from the data.

  • If we construct a model, what type of conclusions will be able to draw from it?

We will be able to see which variables have an affect on whether a booking was canceled. We can then use that information to predict future cancellations.

  1. Create some exploratory plots or table summaries of the variables in the dataset. Be sure to also examine missing values or other interesting values. You may want to adjust the fig.width and fig.height in the code chunk options.
hotels %>%
  select(where(is.numeric)) %>% 
  pivot_longer(cols = everything(),
               names_to = "variable", 
               values_to = "value") %>% 
  ggplot(aes(x = value)) +
  geom_histogram(bins = 30) +
  facet_wrap(vars(variable), 
             scales = "free")

  1. First, we will do a couple things to get the data ready.
  • I did the following for you: made outcome a factor (needs to be that way for logistic regression), made all character variables factors, removed the year variable and some reservation status variables, and removed cases with missing values (not NULLs but true missing values).

  • You need to split the data into a training and test set, stratifying on the outcome variable, is_canceled. Since we have a lot of data, split the data 50/50 between training and test. I have already set.seed() for you. Be sure to use hotels_mod in the splitting.

hotels_mod <- hotels %>% 
  mutate(is_canceled = as.factor(is_canceled)) %>% 
  mutate(across(where(is.character), as.factor)) %>% 
  select(-arrival_date_year,
         -reservation_status,
         -reservation_status_date) %>% 
  add_n_miss() %>% 
  filter(n_miss_all == 0) %>% 
  select(-n_miss_all)

set.seed(494)

# Randomly assigns 50% of the data to training.
hotels_split <- initial_split(hotels_mod, 
                             prop = .50)
hotels_split
## <Analysis/Assess/Total>
## <59693/59693/119386>
#<training/testing/total>

hotels_training <- training(hotels_split)
hotels_testing <- testing(hotels_split)
  1. In this next step, we are going to do the pre-processing. Usually, I won’t tell you exactly what to do here, but for your first exercise, I’ll tell you the steps.
  • Set up the recipe with is_canceled as the outcome and all other variables as predictors (HINT: ~.).
  • Use a step_XXX() function or functions (I think there are other ways to do this, but I found step_mutate_at() easiest) to create some indicator variables for the following variables: children, babies, and previous_cancellations. So, the new variable should be a 1 if the original is more than 0 and 0 otherwise. Make sure you do this in a way that accounts for values that may be larger than any we see in the dataset.
  • For the agent and company variables, make new indicator variables that are 1 if they have a value of NULL and 0 otherwise. I also used step_mutate_at() for this, but there’s more ways you could do it.
  • Use fct_lump_n() inside step_mutate() to lump together countries that aren’t in the top 5 most occurring.
  • If you used new names for some of the new variables you created, then remove any variables that are no longer needed.
  • Use step_normalize() to center and scale all the non-categorical predictor variables. (Do this BEFORE creating dummy variables. When I tried to do it after, I ran into an error - I’m still investigating why.)
  • Create dummy variables for all factors/categorical predictor variables (make sure you have -all_outcomes() in this part!!).
  • Use the prep() and juice() functions to apply the steps to the training data just to check that everything went as planned.
hotels_recipe <- recipe(is_canceled ~ ., #short-cut, . = all other vars
                       data = hotels_training) %>%
  step_mutate_at(children, babies, previous_cancellations,
                 fn = ~ as.numeric(. != 0)) %>%
  step_mutate_at(agent, company,
                 fn = ~ as.numeric(. == "NULL")) %>%
  step_mutate(country = fct_lump_n(country, 5)) %>% 
  step_normalize(all_predictors(), 
                 -all_nominal()) %>% 
  step_dummy(all_nominal(), 
             -all_outcomes()) 
hotels_recipe %>% 
  prep(hotels_training) %>%
  juice() 
  1. In this step we will set up a LASSO model and workflow.
  • In general, why would we want to use LASSO instead of regular logistic regression? (HINT: think about what happens to the coefficients).
  • Define the model type, set the engine, set the penalty argument to tune() as a placeholder, and set the mode.
  • Create a workflow with the recipe and model.
hotels_lasso_mod <- 
  # Define a lasso model 
  # I believe default is mixture = 1 so probably don't need 
  logistic_reg(mixture = 1) %>% 
  # Set the engine to "glmnet" 
  set_engine("glmnet") %>% 
  # The parameters we will tune.
  set_args(penalty = tune()) %>% 
  # Use "regression"
  set_mode("classification")
hotels_lasso_wf <- 
  # Set up the workflow
  workflow() %>% 
  # Add the recipe
  add_recipe(hotels_recipe) %>% 
  # Add the modeling
  add_model(hotels_lasso_mod)

hotels_lasso_wf
## == Workflow ====================================================================
## Preprocessor: Recipe
## Model: logistic_reg()
## 
## -- Preprocessor ----------------------------------------------------------------
## 5 Recipe Steps
## 
## * step_mutate_at()
## * step_mutate_at()
## * step_mutate()
## * step_normalize()
## * step_dummy()
## 
## -- Model -----------------------------------------------------------------------
## Logistic Regression Model Specification (classification)
## 
## Main Arguments:
##   penalty = tune()
##   mixture = 1
## 
## Computational engine: glmnet

A LASSO model is also known as a shrinkage model because it reduces the coefficients in the regression. This also then reduces variance in the model, so if we changed the input variables for the model, the model’s predictions would not change as drastically compared to using a logistic regression.

  1. In this step, we’ll tune the model and fit the model using the best tuning parameter to the entire training dataset.
  • Create a 5-fold cross-validation sample. We’ll use this later. I have set the seed for you.

  • Use the grid_regular() function to create a grid of 10 potential penalty parameters (we’re keeping this sort of small because the dataset is pretty large). Use that with the 5-fold cv data to tune the model.

  • Use the tune_grid() function to fit the models with different tuning parameters to the different cross-validation sets.

  • Use the collect_metrics() function to collect all the metrics from the previous step and create a plot with the accuracy on the y-axis and the penalty term on the x-axis. Put the x-axis on the log scale.

  • Use the select_best() function to find the best tuning parameter, fit the model using that tuning parameter to the entire training set (HINT: finalize_workflow() and fit()), and display the model results using pull_workflow_fit() and tidy(). Are there some variables with coefficients of 0?

set.seed(494) # for reproducibility
hotels_cv <- vfold_cv(hotels_training, v = 5)
penalty_grid <- grid_regular(penalty(),
                             levels = 10)
penalty_grid 
hotels_lasso_tune <- 
  hotels_lasso_wf %>% 
  tune_grid(
    resamples = hotels_cv,
    grid = penalty_grid
    )

hotels_lasso_tune
hotels_lasso_tune %>% 
  collect_metrics() %>% 
  filter(.metric == "accuracy") 
# Visualize rmse vs. penalty
hotels_lasso_tune %>% 
  collect_metrics() %>% 
  filter(.metric == "accuracy") %>% 
  ggplot(aes(x = penalty, y = mean)) +
  geom_point() +
  geom_line() +
  scale_x_log10(
   breaks = scales::trans_breaks("log10", function(x) 10^x),
   labels = scales::trans_format("log10",scales::math_format(10^.x))) +
  labs(x = "penalty", y = "accuracy")

# Best tuning parameter by smallest rmse
best_param <- hotels_lasso_tune %>% 
  select_best(metric = "accuracy")
best_param
hotels_lasso_final_wf <- hotels_lasso_wf %>% 
  finalize_workflow(best_param)
hotels_lasso_final_wf
## == Workflow ====================================================================
## Preprocessor: Recipe
## Model: logistic_reg()
## 
## -- Preprocessor ----------------------------------------------------------------
## 5 Recipe Steps
## 
## * step_mutate_at()
## * step_mutate_at()
## * step_mutate()
## * step_normalize()
## * step_dummy()
## 
## -- Model -----------------------------------------------------------------------
## Logistic Regression Model Specification (classification)
## 
## Main Arguments:
##   penalty = 1e-10
##   mixture = 1
## 
## Computational engine: glmnet
hotels_lasso_final_mod <- hotels_lasso_final_wf %>% 
  fit(data = hotels_training)

hotels_lasso_final_mod %>% 
  pull_workflow_fit() %>% 
  tidy() 

There are two variables with 0 as the coefficient (arrival_date_month_September and distribution_channel_Undefined).

  1. Now that we have a model, let’s evaluate it a bit more. All we have looked at so far is the cross-validated accuracy from the previous step.
  • Create a variable importance graph. Which variables show up as the most important? Are you surprised?
  • Use the last_fit() function to fit the final model and then apply it to the testing data. Report the metrics from the testing data using the collet_metrics() function. How do they compare to the cross-validated metrics?

The accuracy from the model using the testing data is almost exactly the same as the training accuracy. It was different by about 0.03 (0.813814 vs. 0.8161259)

  • Use the collect_predictions() function to find the predicted probabilities and classes for the test data. Save this to a new dataset called preds. Then, use the conf_mat() function from dials (part of tidymodels) to create a confusion matrix showing the predicted classes vs. the true classes. Compute the true positive rate (sensitivity), true negative rate (specificity), and accuracy. See this Wikipedia reference if you (like me) tend to forget these definitions. Also keep in mind that a “positive” in this case is a cancellation (those are the 1’s).
  • Use the preds dataset you just created to create a density plot of the predicted probabilities of canceling (the variable is called .pred_1), filling by is_canceled. Use an alpha = .5 and color = NA in the geom_density(). Answer these questions:
  1. What would this graph look like for a model with an accuracy that was close to 1?

This graph would look like two seperate curves that do not overlap at all.

  1. Our predictions are classified as canceled if their predicted probability of canceling is greater than .5. If we wanted to have a high true positive rate, should we make the cutoff for predicted as canceled higher or lower than .5?

If we wanted to make a higher true positive rate we should make the cutoff higher. Then, the predicted probability of a cancelation must be greater in order to classify it as canceled. So we won’t get as many positive predictions when in fact the actual result was not a cancelation.

  1. What happens to the true negative rate if we try to get a higher true positive rate?

The true negative rate would decrease because there would be larger amounts of false negative predictions.

# Fit model with best tuning parameter(s) to training data and apply to test data
hotels_lasso_test <- hotels_lasso_final_wf %>% 
  last_fit(hotels_split)

# Metrics for model applied to test data
hotels_lasso_test %>% 
  collect_metrics()
preds <- 
  collect_predictions(hotels_lasso_test)
conf_mat(preds,.pred_class, is_canceled)
##           Truth
## Prediction     0     1
##          0 34221  3380
##          1  7734 14358

The True Positive Rate is 14,358/17738= 80.9%. The True Negative Rate is 34221/41955= 81.5%

preds %>%
ggplot() +
  geom_density(aes(x = .pred_1, fill=is_canceled))+
  labs(title = "Predicted Probabilities",
       x= "Predicted Probabilities of Canceling")

  1. Let’s say that this model is going to be applied to bookings 14 days in advance of their arrival at each hotel, and someone who works for the hotel will make a phone call to the person who made the booking. During this phone call, they will try to assure that the person will be keeping their reservation or that they will be canceling in which case they can do that now and still have time to fill the room. How should the hotel go about deciding who to call? How could they measure whether it was worth the effort to do the calling? Can you think of another way they might use the model?

The hotel should call the customers that are predicted to cancel their booking. If they did that, they could possibly re-book about half of the people’s reservations who will eventually end up cancelling. They should measure the success by how many of the bookings they can cancel early and rebook because that is profit gained from the model. They could also use this model to create a refundable deposit policy for how to go about allowing peole to cancel.

  1. How might you go about questioning and evaluating the model in terms of fairness? Are there any questions you would like to ask of the people who collected the data?

Thinking about fairness in this model I could see some customers getting upset about the hotel calling them and asking them if they are cancelling based of factors that they may or may not have been able to control. Customer’s may take the question as calling them irresponsible for not possibly fufilling there initial commitment to a booking. A question I would ask for the data collecting the data would be “how are all groups (poor vs. wealthy families) represented within the dataset?”

Bias and Fairness

Read Chapter 1: The Power Chapter of Data Feminism by Catherine D’Ignazio and Lauren Klein. Write a 4-6 sentence paragraph reflecting on this chapter. As you reflect, you might consider responding to these specific questions. We will also have a discussion about these questions in class on Thursday.

  • At the end of the “Matrix of Domination” section, they encourage us to “ask uncomfortable questions: who is doing the work of data science (and who is not)? Whose goals are prioritized in data science (and whose are not)? And who benefits from data science (and who is either overlooked or actively harmed)?” In general, how would you answer these questions? And why are they important?
  • Can you think of any examples of missing datasets, like those described in the “Data Science for Whom?” section? Or was there an example there that surprised you?
  • How did the examples in the “Data Science with Whose Interests and Goals?” section make you feel? What responsibility do companies have to prevent these things from occurring? Who is to blame?

Taking into account the questions asked by the article, I think the field of Data Science can be compared to many other STEM related fields. Women and minority genders are underrepresented in the job market, but also in the actually topics studied in the field as well. For example, the AI facial recognition model was created with bias because the data collected/used to train the model underrepresented minority groups. Another example from the article deals with Amazon’s resume screening model that completely disregards the difference in male and female resume’s due to the dataset used to train the model. It seems like there is a pattern with these projects and how they disregard certain groups. One section of the article that surprised me was the Data Science with Whose Interests and Goals. It felt as if there is no way around this problem if you were so set on collecting data for this problem unless this data was voluntarily given. Which due to the topic of the study, parents would be reluctant to give that information. I think we can blame the person responsible for collecting the data, because they need to think about the chance that certain groups would be misrepresented just as if the roles were reversed between the poor and rich families.

LS0tDQp0aXRsZTogJ0Fzc2lnbm1lbnQgIzInDQpvdXRwdXQ6IA0KICBodG1sX2RvY3VtZW50Og0KICAgIHRvYzogdHJ1ZQ0KICAgIHRvY19mbG9hdDogdHJ1ZQ0KICAgIGRmX3ByaW50OiBwYWdlZA0KICAgIGNvZGVfZG93bmxvYWQ6IHRydWUNCi0tLQ0KDQpgYGB7ciBzZXR1cCwgaW5jbHVkZT1GQUxTRX0NCmtuaXRyOjpvcHRzX2NodW5rJHNldChlY2hvID0gVFJVRSwgbWVzc2FnZT1GQUxTRSwgd2FybmluZz1GQUxTRSkNCmBgYA0KDQpgYGB7ciBsaWJyYXJpZXN9DQpsaWJyYXJ5KHRpZHl2ZXJzZSkgICAgICAgICAjIGZvciBncmFwaGluZyBhbmQgZGF0YSBjbGVhbmluZw0KbGlicmFyeSh0aWR5bW9kZWxzKSAgICAgICAgIyBmb3IgbW9kZWxpbmcNCmxpYnJhcnkobmFuaWFyKSAgICAgICAgICAgICMgZm9yIGFuYWx5emluZyBtaXNzaW5nIHZhbHVlcw0KbGlicmFyeSh2aXApICAgICAgICAgICAgICAgIyBmb3IgdmFyaWFibGUgaW1wb3J0YW5jZSBwbG90cw0KdGhlbWVfc2V0KHRoZW1lX21pbmltYWwoKSkgIyBMaXNhJ3MgZmF2b3JpdGUgdGhlbWUNCmBgYA0KDQpgYGB7ciBkYXRhfQ0KaG90ZWxzIDwtIHJlYWRyOjpyZWFkX2NzdignaHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL3Jmb3JkYXRhc2NpZW5jZS90aWR5dHVlc2RheS9tYXN0ZXIvZGF0YS8yMDIwLzIwMjAtMDItMTEvaG90ZWxzLmNzdicpDQpgYGANCg0KDQpXaGVu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